package com.ray.friendslist.content.provider;

import org.json.JSONException;
import org.json.JSONObject;

import android.content.ContentValues;
import android.net.Uri;
import android.util.Log;

import com.ray.friendslist.content.contract.FriendsContract;
import com.ray.friendslist.content.provider.common.CommonProvider;
import com.ray.friendslist.wall.WallEntity;

public class UserProfileInfoProvider extends CommonProvider {

	@Override
	protected String getOrderBy() {
		return FriendsContract.UserInfoColumns.UNCONVERTED_DATE + " DESC";
	}

	@Override
	protected String getTableName() {
		return FriendsContract.UserInfoColumns.TABLE_NAME;
	}

	@Override
	protected String getContentType() {
		return FriendsContract.UserInfoColumns.CONTENT_TYPE;
	}

	@Override
	protected Uri getContentURI() {
		return FriendsContract.UserInfoColumns.CONTENT_URI;
	}

	@Override
	protected String[] getColoumns() {
		return FriendsContract.UserInfoColumns.COLOUMNS;
	}

	@Override
	protected ContentValues getContentValues(JSONObject jsonObject)
			throws JSONException {
		ContentValues contentValues = new ContentValues();
		WallEntity entity = new WallEntity(jsonObject);
		Log.i("ray", "CONTENT VALUES --- " + entity.getString("date"));
		contentValues.put(FriendsContract.UserInfoColumns.ITEM_ID,
				jsonObject.getString("id"));
		contentValues.put(FriendsContract.UserInfoColumns.DATE,
				entity.getItemDate());
		contentValues.put(FriendsContract.UserInfoColumns.UNCONVERTED_DATE,
				jsonObject.getString("date"));
		contentValues.put(FriendsContract.UserInfoColumns.TEXT,
				entity.getFeedText());
		contentValues.put(FriendsContract.UserInfoColumns.PROFILE_NAME,
				entity.getItemName());
		contentValues.put(FriendsContract.UserInfoColumns.PROFILE_PHOTO,
				jsonObject.getString("photo"));
		contentValues.put(FriendsContract.UserInfoColumns.ATTACHMENT_PHOTO,
				entity.getWallAttachments());
		contentValues.put(FriendsContract.UserInfoColumns.LIKES,
				entity.getItemLikes());
		contentValues.put(FriendsContract.UserInfoColumns.USER_ID,
				jsonObject.getString("to_id"));
		return contentValues;
	}

}
